package com.liuzihao.service.impl;

import com.liuzihao.service.IMessageProvider;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.MessageChannel;

import javax.annotation.Resource;
import java.util.UUID;

/**
 * @Author: Liuzihao
 * @Description:
 * @Date Created in 2022-03-10 17:14
 * @Modified By:
 */
@EnableBinding(Source.class)
public class IMessageProviderImpl implements IMessageProvider {
    @Resource
    MessageChannel output;//这个名字是一个通道的名称,查看配置cloud.stream.bindings
    @Override
    public String sendMsg() {
        String serial = UUID.randomUUID().toString();
        output.send(MessageBuilder.withPayload(serial).build());
        System.out.println("*****serial: " +serial);
        return "success";
    }
}
